#include "tts.h"

TTS::TTS(QObject *parent) : QObject(parent)
{

}

void TTS::TTSPlay(QString addr)
{
    if(QSysInfo::buildCpuArchitecture() == "arm"){
         qDebug()<< "addr this : " +  addr<<endl;
        system(QString("mplayer -af volume=15 %1").arg(addr).toLatin1());
    }
    else{
        qDebug()<< "tts ok!,addr this : " +  addr<<endl;
    }
}

void TTS::PriceTTS(uint Price)
{
    unsigned int thousands_digit = 0;
    unsigned int hundreds_digit = 0;
    unsigned int ten_digit = 0;
    unsigned int single_digit = 0;

    thousands_digit = Price /  1000;
    hundreds_digit  = Price %  1000 / 100;
    ten_digit       = Price %  1000 % 100 / 10;
    single_digit    = Price %  1000 % 100 %10;

    /* TTS */
    system("mplayer -af volume=15 /bishe/yuyin/xiaofei.wav");
    if(thousands_digit != 0){
        system(QString("mplayer -af volume=15 /bishe/yuyin/%1.wav").arg(thousands_digit).toLatin1());
        system("mplayer -af volume=15 /bishe/yuyin/qian.wav");
    }
    if(hundreds_digit != 0){
        system(QString("mplayer -af volume=15 /bishe/yuyin/%1.wav").arg(hundreds_digit).toLatin1());
        system("mplayer -af volume=15 /bishe/yuyin/bai.wav");
    }
    if(ten_digit != 0){
        system(QString("mplayer -af volume=15 /bishe/yuyin/%1.wav").arg(ten_digit).toLatin1());
        system("mplayer -af volume=15 /bishe/yuyin/10.wav");
    }
    system(QString("mplayer -af volume=15 /bishe/yuyin/%1.wav").arg(single_digit).toLatin1());
    system("mplayer -af volume=15 /bishe/yuyin/yuan.wav");
}
